﻿using Kavaa.Core.Data;
using Kavaa.Modules.PortailMedical.Entity;
using System;


namespace Kavaa.Modules.PortailMedical.Datalayer
{
    class NomenclatureDAO
    {
        public static Nomenclatures GetNomenclatures()
        {
            Nomenclatures nomenclatures = new Nomenclatures();

            foreach (var row in SqlDaoAdapter.ExecuteReader(
                ConfigurationCache.DatabaseConnectionString,
                "[dbo].[sp_PortailMedical_GetNomenclatures]"
           ))
            {
                nomenclatures.Add(new Nomenclature()
                {
                    Id = (row["NomenclatureId"] != DBNull.Value) ? Convert.ToInt32(row["NomenclatureId"]) : 0,
                    Name = (row["NomenclatureName"] != DBNull.Value) ? Convert.ToString(row["NomenclatureName"]) : null,
                });
            }

            return nomenclatures;
        }
    }
}
